# encoding:utf-8
"""
===============***===============
Auther : Hsir
Date   : 2022 - 11 - 21   14:08
File   : conftest.py
===============***===============
"""
import pytest

from autotest04.comms.dbutils import DBUtils


@pytest.fixture(scope="function")  # 无autouse=True,非自动，需要在case中手动输入才可
def function():
    print("====这是conftest.py的函数级别固件开始====")
    yield
    print("====这是conftest.py的函数级别固件结束====")


@pytest.fixture(scope="class")  # # 非自动，需要在case中手动输入才可
def class_fixture():
    print("-----====这是conftest.py的类级别固件开始====-----")
    yield
    print("-----====这是conftest.py的类数级别固件结束====-----")



def pytest_collection_modifyitems(items):
    """
    测试用例收集完成时，将收集到的name和nodeid的中文显示在控制台上
    """
    for i in items:
        i.name = i.name.encode("utf-8").decode("unicode_escape")
        print(i.nodeid)
        i._nodeid = i.nodeid.encode("utf-8").decode("unicode_escape")


@pytest.fixture(scope="class")
def db():
    # print("类开始前运行")
    d = DBUtils()
    yield d
    d.close()
    # print("类结束后运行")
